<template>
  <div>
    <van-tabbar
      active-color="#f66"
      :route="true"
      inactive-color="#333">
       <van-tabbar-item to="/home">
        <span>首页</span>
        <template #icon="props">
          <van-icon class="iconfont" class-prefix="icon" name="shouye"/>
        </template>
      </van-tabbar-item>
      <van-tabbar-item to="/cate">
        <span>分类</span>
        <template #icon="props">
          <van-icon class="iconfont" class-prefix="icon" name="fenlei"/>
        </template>
      </van-tabbar-item>
      <van-tabbar-item to="/cart" :badge="cart.items.length === 0 ? '': cart.items.length ">
        <span>购物车</span>
        <template #icon="props">
          <van-icon class="iconfont" class-prefix="icon" name="gouwuche"/>
        </template>
      </van-tabbar-item>
      <van-tabbar-item to="/mine">
        <span>我的</span>
        <template #icon="props">
          <van-icon class="iconfont" class-prefix="icon" name="weibiaoti2fuzhi12"/>
        </template>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  computed: {
    ...mapState({
      cart: state => state.cart.cart
    })
  }
}
</script>
